<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head th:replace="common/layout :: common_header(~{::title},~{::link})">
<title>新建请假流程</title>
</head>
<body>
	<div class="main-container">
		<div class="main-content-inner">
			<div class="page-content">
				<div class="row">
					<form class="form-horizontal" role="form" id="oaForm" method="post" th:action="@{/oa/leave/saveLeave}" >
						<div class="control-group">
							<label class="control-label">标题：</label>
							<div class="controls">
								<input type="text" name="title" class="form-control" required rows="5" maxlength="20"/>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">请假类型：</label>
							<div class=" controls">
								<select name="leaveType" class="form-control">
									<option value="1">调休</option>
									<option value="2">年假</option>
									<option value="3">事假</option>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">开始时间：</label>
							<div class=" controls">
								<input id="startTime" name="startTime" type="text"
									readonly="readonly" maxlength="20" class="Wdate required"
									onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" required/>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">结束时间：</label>
							<div class="controls">
								<input id="endTime" name="endTime" type="text"
									readonly="readonly" maxlength="20" class="Wdate required"
									onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});" required/>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">实际请假时间：</label>
							<div class="controls">
								<input id="timeUsed" name="timeUsed" type="text" 
									  maxlength="20"  required
									 />小时
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">请假原因：</label>
							<div class="controls">
								<textarea name="reason" class="form-control" required rows="3" maxlength="200"></textarea>
							</div>
						</div>
						<input type="hidden" id="status" name="status" value="0">
						</form>
						<div class="clearfix ">
							<div class="center">
							
								<button class="btn btn-sm btn-primary" type="button" id="saveBtn">
									  保存草稿
								</button>
								<button class="btn btn-lg btn-success" type="button" id="submitBtn">
									  发起流程
								</button>
									<button class="btn btn-sm " type="button" id="closeWin">
									  关闭
								</button>
								
							</div>
						</div>
					
				</div>
				<!-- /.col -->
			</div>

		</div>
		<!-- end main container -->
	</div>

	<div th:replace="common/commonJS"></div>
	<script th:src="@{/ace/plugins/My97DatePicker/WdatePicker.js}"></script> 
	<script type="text/javascript">
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	//关闭iframe
	$('#closeWin').click(function(){
	    top.layer.close(index);
	});
	$('#saveBtn').click(function(){
	    $("#status").val("0");
	    $("#oaForm").submit();
	 });
	$('#submitBtn').click(function(){
	    $("#status").val("1");
	    $("#oaForm").submit();
	 });
	 $().ready(function() {
		    $("#oaForm").validate({
		    	submitHandler: function(form) { 
	        		//验证通过后 的js代码写在这里 
	        		
		    		 $(form).ajaxSubmit({
		                 dataType:"json",
		                 success:function( result ){
		                      if(result.code==0){
		                    	  top.layer.alert('保存成功') 
		                    	  top.layer.close(index);
		                    	  if(top.getActiveTab()[0]){
		                    		  top.getActiveTab()[0].contentWindow.search();
		                    	  }
		                    	  
		                      }else{
		                    	  top.layer.alert('保存失败')  
		                      }
		                        
		                    
		                   },
		                   error:function(xhr, status, error){
		                	   top.layer.alert('操作失败');
		                   }
		                 });
	         
	        		}
		    });
		});
	</script>
</body>
</html>